from django.db import models


class Environment(models.Model):
    '''
    环境
    '''
    envid = models.IntegerField(db_column='EnvID', primary_key=True, auto_created=True)  # Field name made lowercase.
    envname = models.CharField(db_column='EnvName', max_length=50, unique=True)  # Field name made lowercase.
    ip = models.CharField(db_column='IP', max_length=40, unique=True)  # Field name made lowercase.
    updatetime = models.CharField(db_column='UpdateTime', max_length=19)  # Field name made lowercase.
    type = models.CharField(db_column='Type', max_length=1)  # Field name made lowercase.
    backtype = models.CharField(db_column='BackType', max_length=1)  # Field name made lowercase.
    runpath = models.CharField(db_column='RunPath', max_length=1000)  # Field name made lowercase.
    remark = models.CharField(db_column='Remark', max_length=500)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_environment'


class Liveapproval(models.Model):
    '''
    实盘审批
    '''
    stgid = models.IntegerField(db_column='StgID', primary_key=True)  # Field name made lowercase.
    envid = models.CharField(db_column='EnvID', max_length=20)  # Field name made lowercase.
    remark = models.CharField(db_column='Remark', max_length=500)  # Field name made lowercase.
    audittime = models.CharField(db_column='AuditTime', max_length=19)  # Field name made lowercase.
    inserttime = models.CharField(db_column='InsertTime', max_length=19)  # Field name made lowercase.
    auditstatus = models.CharField(db_column='AuditStatus', max_length=1)  # Field name made lowercase.
    auditmsg = models.CharField(db_column='AuditMsg', max_length=2000)  # Field name made lowercase.
    packstatus = models.CharField(db_column='PackStatus', max_length=1)  # Field name made lowercase.
    packmsg = models.CharField(db_column='PackMsg', max_length=2000)  # Field name made lowercase.
    packtime = models.CharField(db_column='PackTime', max_length=19)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_liveapproval'


class Livereturn(models.Model):
    '''
    业绩分析：实盘回报
    '''
    id = models.AutoField(db_column='ID', primary_key=True)  # Field name made lowercase.
    stgid = models.IntegerField(db_column='StgID')  # Field name made lowercase.
    batchid = models.IntegerField(db_column='BatchID')  # Field name made lowercase.
    data = models.TextField()
    date = models.TextField()
    heatyear = models.TextField(db_column='heatYear')  # Field name made lowercase.
    heatdata = models.TextField(db_column='heatData')  # Field name made lowercase.
    yearlyretdate = models.TextField(db_column='yearlyRetDate')  # Field name made lowercase.
    yearlyretdata = models.TextField(db_column='yearlyRetData')  # Field name made lowercase.
    monthlyretdistdata = models.TextField(db_column='monthlyRetDistData')  # Field name made lowercase.
    boxdata = models.TextField(db_column='boxData')  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_livereturn'
        unique_together = (('id', 'stgid', 'batchid'),)


class Livestgpara(models.Model):
    '''
    实盘策略参数
    '''
    stgid = models.IntegerField(db_column='StgID', primary_key=True)  # Field name made lowercase.
    propkey = models.CharField(db_column='PropKey', max_length=32)  # Field name made lowercase.
    propvalue = models.CharField(db_column='PropValue', max_length=256)  # Field name made lowercase.
    proptype = models.CharField(db_column='PropType', max_length=1)  # Field name made lowercase.
    provalueitems = models.CharField(db_column='ProValueItems', max_length=200)  # Field name made lowercase.
    description = models.CharField(db_column='Description', max_length=400)  # Field name made lowercase.
    updatetime = models.CharField(db_column='UpdateTime', max_length=19)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_livestgpara'


class Livesummary(models.Model):
    '''
    业绩分析：实盘指标
    '''
    id = models.AutoField(db_column='ID', primary_key=True)  # Field name made lowercase.
    stgid = models.IntegerField(db_column='StgID')  # Field name made lowercase.
    batchid = models.IntegerField(db_column='BatchID')  # Field name made lowercase.
    simtime = models.CharField(db_column='SimTime', max_length=19)  # Field name made lowercase.
    simstartdate = models.CharField(db_column='SimStartDate', max_length=10)  # Field name made lowercase.
    simenddate = models.CharField(db_column='SimEndDate', max_length=10)  # Field name made lowercase.
    totaldays = models.IntegerField(db_column='TotalDays')  # Field name made lowercase.
    pl = models.FloatField(db_column='PL')  # Field name made lowercase.
    maxdrawndown = models.FloatField(db_column='MaxDrawndown')  # Field name made lowercase.
    maxdrawndowndays = models.IntegerField(db_column='MaxDrawndownDays')  # Field name made lowercase.
    sharpratio = models.FloatField(db_column='SharpRatio')  # Field name made lowercase.
    calmarratio = models.FloatField(db_column='CalmarRatio')  # Field name made lowercase.
    windays = models.IntegerField(db_column='WinDays')  # Field name made lowercase.
    lossdays = models.IntegerField(db_column='LossDays')  # Field name made lowercase.
    windaysrate = models.FloatField(db_column='WinDaysRate')  # Field name made lowercase.
    totaltrans = models.IntegerField(db_column='TotalTrans')  # Field name made lowercase.
    wintrans = models.IntegerField(db_column='WinTrans')  # Field name made lowercase.
    losstrans = models.IntegerField(db_column='LossTrans')  # Field name made lowercase.
    wintransrate = models.FloatField(db_column='WinTransRate')  # Field name made lowercase.
    avgtradeprofit = models.FloatField(db_column='AvgTradeProfit')  # Field name made lowercase.
    avgdailyprofit = models.FloatField(db_column='AvgDailyProfit')  # Field name made lowercase.
    beginnetvalue = models.FloatField(db_column='BeginNetValue')  # Field name made lowercase.
    endnetvalue = models.FloatField(db_column='EndNetValue')  # Field name made lowercase.
    summaryscore = models.IntegerField(db_column='SummaryScore')  # Field name made lowercase.
    annualret = models.FloatField(db_column='AnnualRet')  # Field name made lowercase.
    profitscore = models.IntegerField(db_column='ProfitScore')  # Field name made lowercase.
    costperfscore = models.IntegerField(db_column='CostPerfScore')  # Field name made lowercase.
    stabscore = models.IntegerField(db_column='StabScore')  # Field name made lowercase.
    capitalscore = models.IntegerField(db_column='CapitalScore')  # Field name made lowercase.
    sensitivityscore = models.IntegerField(db_column='SensitivityScore')  # Field name made lowercase.
    annualvolatility = models.FloatField(db_column='AnnualVolatility')  # Field name made lowercase.
    stabilityoftimeseries = models.FloatField(db_column='StabilityOfTimeseries')  # Field name made lowercase.
    omegaratio = models.FloatField(db_column='OmegaRatio')  # Field name made lowercase.
    sortinoratio = models.FloatField(db_column='SortinoRatio')  # Field name made lowercase.
    skew = models.FloatField(db_column='Skew')  # Field name made lowercase.
    kurtosis = models.FloatField(db_column='Kurtosis')  # Field name made lowercase.
    tailratio = models.FloatField(db_column='TailRatio')  # Field name made lowercase.
    commonsenseratio = models.FloatField(db_column='CommonSenseRatio')  # Field name made lowercase.
    cumreturnsfinal = models.FloatField(db_column='CumReturnsFinal')  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_livesummary'
        unique_together = (('id', 'stgid', 'batchid'),)


class Operationlog(models.Model):
    '''
    操作日志
    '''
    sequenceno = models.IntegerField(db_column='SequenceNo', primary_key=True)  # Field name made lowercase.
    customerid = models.CharField(db_column='CustomerID', max_length=20)  # Field name made lowercase.
    modular = models.CharField(db_column='Modular', max_length=1)  # Field name made lowercase.
    optfunction = models.CharField(db_column='OPTFunction', max_length=100)  # Field name made lowercase.
    optinfo = models.CharField(db_column='OPTInfo', max_length=500)  # Field name made lowercase.
    opttime = models.CharField(db_column='OPTTime', max_length=19)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_operationlog'


class Paperapproval(models.Model):
    '''
    仿真监控
    '''
    stgid = models.IntegerField(db_column='StgID', primary_key=True)  # Field name made lowercase.
    envid = models.CharField(db_column='EnvID', max_length=20)  # Field name made lowercase.
    remark = models.CharField(db_column='Remark', max_length=500)  # Field name made lowercase.
    updatetime = models.CharField(db_column='UpdateTime', max_length=19)  # Field name made lowercase.
    auditstatus = models.CharField(db_column='AuditStatus', max_length=1)  # Field name made lowercase.
    auditmsg = models.CharField(db_column='AuditMsg', max_length=2000)  # Field name made lowercase.
    packstatus = models.CharField(db_column='PackStatus', max_length=1)  # Field name made lowercase.
    packmsg = models.CharField(db_column='PackMsg', max_length=2000)  # Field name made lowercase.
    packtime = models.CharField(db_column='PackTime', max_length=19)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_paperapproval'


class Paperreturn(models.Model):
    '''
    业绩分析，仿真回报
    '''
    id = models.AutoField(db_column='ID', primary_key=True)  # Field name made lowercase.
    stgid = models.IntegerField(db_column='StgID')  # Field name made lowercase.
    batchid = models.IntegerField(db_column='BatchID')  # Field name made lowercase.
    data = models.TextField()
    date = models.TextField()
    heatyear = models.TextField(db_column='heatYear')  # Field name made lowercase.
    heatdata = models.TextField(db_column='heatData')  # Field name made lowercase.
    yearlyretdate = models.TextField(db_column='yearlyRetDate')  # Field name made lowercase.
    yearlyretdata = models.TextField(db_column='yearlyRetData')  # Field name made lowercase.
    monthlyretdistdata = models.TextField(db_column='monthlyRetDistData')  # Field name made lowercase.
    boxdata = models.TextField(db_column='boxData')  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_paperreturn'
        unique_together = (('id', 'stgid', 'batchid'),)


class Paperstgpara(models.Model):
    '''
    仿真策略参数
    '''
    stgid = models.IntegerField(db_column='StgID', primary_key=True)  # Field name made lowercase.
    propkey = models.CharField(db_column='PropKey', max_length=32)  # Field name made lowercase.
    propvalue = models.CharField(db_column='PropValue', max_length=256)  # Field name made lowercase.
    proptype = models.CharField(db_column='PropType', max_length=1)  # Field name made lowercase.
    provalueitems = models.CharField(db_column='ProValueItems', max_length=200)  # Field name made lowercase.
    description = models.CharField(db_column='Description', max_length=400)  # Field name made lowercase.
    updatetime = models.CharField(db_column='UpdateTime', max_length=19)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_paperstgpara'


class Ruleprop(models.Model):
    '''
    策略参数
    '''
    ruleid = models.IntegerField(db_column='RuleID', primary_key=True)  # Field name made lowercase.
    propkey = models.CharField(db_column='PropKey', max_length=32)  # Field name made lowercase.
    propvalue = models.CharField(db_column='PropValue', max_length=256)  # Field name made lowercase.
    proptype = models.CharField(db_column='PropType', max_length=1)  # Field name made lowercase.
    provalueitems = models.CharField(db_column='PropValueItems', max_length=200)  # Field name made lowercase.
    description = models.CharField(db_column='Description', max_length=400)  # Field name made lowercase.

    # updatetime = models.CharField(db_column='UpdateTime', max_length=19)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_ruleprop'


class Papersummary(models.Model):
    '''
    业绩分析，仿真指标
    '''
    id = models.AutoField(db_column='ID', primary_key=True)  # Field name made lowercase.
    stgid = models.IntegerField(db_column='StgID')  # Field name made lowercase.
    batchid = models.IntegerField(db_column='BatchID')  # Field name made lowercase.
    simtime = models.CharField(db_column='SimTime', max_length=19)  # Field name made lowercase.
    simstartdate = models.CharField(db_column='SimStartDate', max_length=10)  # Field name made lowercase.
    simenddate = models.CharField(db_column='SimEndDate', max_length=10)  # Field name made lowercase.
    totaldays = models.IntegerField(db_column='TotalDays')  # Field name made lowercase.
    pl = models.FloatField(db_column='PL')  # Field name made lowercase.
    maxdrawndown = models.FloatField(db_column='MaxDrawndown')  # Field name made lowercase.
    maxdrawndowndays = models.IntegerField(db_column='MaxDrawndownDays')  # Field name made lowercase.
    sharpratio = models.FloatField(db_column='SharpRatio')  # Field name made lowercase.
    calmarratio = models.FloatField(db_column='CalmarRatio')  # Field name made lowercase.
    windays = models.IntegerField(db_column='WinDays')  # Field name made lowercase.
    lossdays = models.IntegerField(db_column='LossDays')  # Field name made lowercase.
    windaysrate = models.FloatField(db_column='WinDaysRate')  # Field name made lowercase.
    totaltrans = models.IntegerField(db_column='TotalTrans')  # Field name made lowercase.
    wintrans = models.IntegerField(db_column='WinTrans')  # Field name made lowercase.
    losstrans = models.IntegerField(db_column='LossTrans')  # Field name made lowercase.
    wintransrate = models.FloatField(db_column='WinTransRate')  # Field name made lowercase.
    avgtradeprofit = models.FloatField(db_column='AvgTradeProfit')  # Field name made lowercase.
    avgdailyprofit = models.FloatField(db_column='AvgDailyProfit')  # Field name made lowercase.
    beginnetvalue = models.FloatField(db_column='BeginNetValue')  # Field name made lowercase.
    endnetvalue = models.FloatField(db_column='EndNetValue')  # Field name made lowercase.
    summaryscore = models.IntegerField(db_column='SummaryScore')  # Field name made lowercase.
    annualret = models.FloatField(db_column='AnnualRet')  # Field name made lowercase.
    profitscore = models.IntegerField(db_column='ProfitScore')  # Field name made lowercase.
    costperfscore = models.IntegerField(db_column='CostPerfScore')  # Field name made lowercase.
    stabscore = models.IntegerField(db_column='StabScore')  # Field name made lowercase.
    capitalscore = models.IntegerField(db_column='CapitalScore')  # Field name made lowercase.
    sensitivityscore = models.IntegerField(db_column='SensitivityScore')  # Field name made lowercase.
    annualvolatility = models.FloatField(db_column='AnnualVolatility')  # Field name made lowercase.
    stabilityoftimeseries = models.FloatField(db_column='StabilityOfTimeseries')  # Field name made lowercase.
    omegaratio = models.FloatField(db_column='OmegaRatio')  # Field name made lowercase.
    sortinoratio = models.FloatField(db_column='SortinoRatio')  # Field name made lowercase.
    skew = models.FloatField(db_column='Skew')  # Field name made lowercase.
    kurtosis = models.FloatField(db_column='Kurtosis')  # Field name made lowercase.
    tailratio = models.FloatField(db_column='TailRatio')  # Field name made lowercase.
    commonsenseratio = models.FloatField(db_column='CommonSenseRatio')  # Field name made lowercase.
    cumreturnsfinal = models.FloatField(db_column='CumReturnsFinal')  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_papersummary'
        unique_together = (('id', 'stgid', 'batchid'),)


class Strategy(models.Model):
    '''
    策略
    '''
    stgid = models.IntegerField(db_column='StgID', primary_key=True)  # Field name made lowercase.
    stgname = models.CharField(db_column='StgName', max_length=50)  # Field name made lowercase.
    createtime = models.CharField(db_column='CreateTime', max_length=19)  # Field name made lowercase.
    backupdatetime = models.CharField(db_column='BackUpdateTime', max_length=19, blank=True,
                                      null=True)  # Field name made lowercase.
    backtest = models.IntegerField(db_column='BackTest')  # Field name made lowercase.
    status = models.CharField(db_column='Status', max_length=1)  # Field name made lowercase.
    stgfile = models.TextField(db_column='StgFile')  # Field name made lowercase.
    stggroup = models.CharField(db_column='StgGroup', max_length=1)  # Field name made lowercase.
    paperisdelete = models.SmallIntegerField(db_column='PaperIsDelete', default=1)  # Field name made lowercase.
    liveisdelete = models.SmallIntegerField(db_column='LiveIsDelete', default=1)  # Field name made lowercase.
    customerid = models.CharField(db_column='CustomerID', max_length=20)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_strategy'


class CustomerLive(models.Model):
    customerid = models.CharField(db_column='CustomerID', primary_key=True, max_length=20)  # Field name made lowercase.
    customername = models.CharField(db_column='CustomerName', max_length=50)  # Field name made lowercase.
    password = models.CharField(db_column='Password', max_length=100)  # Field name made lowercase.
    isactive = models.SmallIntegerField(db_column='IsActive')  # Field name made lowercase.
    maxlogined = models.IntegerField(db_column='MaxLogined')  # Field name made lowercase.
    usertype = models.IntegerField(db_column='UserType')  # Field name made lowercase.
    createtime = models.CharField(db_column='CreateTime', max_length=19, blank=True,
                                  null=True)  # Field name made lowercase.
    updatetime = models.CharField(db_column='UpdateTime', max_length=19, blank=True,
                                  null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_customer_live'


class CustomerPaper(models.Model):
    customerid = models.CharField(db_column='CustomerID', primary_key=True, max_length=20)  # Field name made lowercase.
    customername = models.CharField(db_column='CustomerName', max_length=50)  # Field name made lowercase.
    password = models.CharField(db_column='Password', max_length=100)  # Field name made lowercase.
    isactive = models.SmallIntegerField(db_column='IsActive')  # Field name made lowercase.
    maxlogined = models.IntegerField(db_column='MaxLogined')  # Field name made lowercase.
    usertype = models.IntegerField(db_column='UserType')  # Field name made lowercase.
    createtime = models.CharField(db_column='CreateTime', max_length=19, blank=True,
                                  null=True)  # Field name made lowercase.
    updatetime = models.CharField(db_column='UpdateTime', max_length=19, blank=True,
                                  null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_customer_paper'


class Customer(models.Model):
    customerid = models.CharField(db_column='CustomerID', primary_key=True, max_length=20)  # Field name made lowercase.
    customername = models.CharField(db_column='CustomerName', max_length=50)  # Field name made lowercase.
    password = models.CharField(db_column='Password', max_length=100)  # Field name made lowercase.
    isactive = models.SmallIntegerField(db_column='IsActive')  # Field name made lowercase.
    maxlogined = models.IntegerField(db_column='MaxLogined')  # Field name made lowercase.
    usertype = models.IntegerField(db_column='UserType')  # Field name made lowercase.
    createtime = models.CharField(db_column='CreateTime', max_length=19, blank=True,
                                  null=True)  # Field name made lowercase.
    updatetime = models.CharField(db_column='UpdateTime', max_length=19, blank=True,
                                  null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_customer'


class CustomerchannelrelLive(models.Model):
    id = models.AutoField(db_column='ID', primary_key=True)  # Field name made lowercase.
    customerid = models.CharField(db_column='CustomerID', max_length=20)  # Field name made lowercase.
    tdchannelid = models.CharField(db_column='TDChannelID', max_length=31, blank=True,
                                   null=True)  # Field name made lowercase.
    mdchannelid = models.CharField(db_column='MDChannelID', max_length=31, blank=True,
                                   null=True)  # Field name made lowercase.
    accountid = models.CharField(db_column='AccountID', max_length=32)  # Field name made lowercase.
    tdapitype = models.CharField(db_column='TDApiType', max_length=1, blank=True,
                                 null=True)  # Field name made lowercase.
    assetno = models.CharField(db_column='AssetNo', max_length=16)  # Field name made lowercase.
    combino = models.CharField(db_column='CombiNo', max_length=20)  # Field name made lowercase.
    apiaccountid = models.CharField(db_column='APIAccountID', max_length=32, blank=True,
                                    null=True)  # Field name made lowercase.
    apiinvestorid = models.CharField(db_column='APIInvestorID', max_length=20, blank=True,
                                     null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_customerchannelrel_live'
        unique_together = (('id', 'customerid', 'accountid'),)


class CustomerchannelrelPaper(models.Model):
    id = models.AutoField(db_column='ID', primary_key=True)  # Field name made lowercase.
    customerid = models.CharField(db_column='CustomerID', max_length=20)  # Field name made lowercase.
    tdchannelid = models.CharField(db_column='TDChannelID', max_length=31, blank=True,
                                   null=True)  # Field name made lowercase.
    mdchannelid = models.CharField(db_column='MDChannelID', max_length=31, blank=True,
                                   null=True)  # Field name made lowercase.
    accountid = models.CharField(db_column='AccountID', max_length=32)  # Field name made lowercase.
    tdapitype = models.CharField(db_column='TDApiType', max_length=1, blank=True,
                                 null=True)  # Field name made lowercase.
    assetno = models.CharField(db_column='AssetNo', max_length=16)  # Field name made lowercase.
    combino = models.CharField(db_column='CombiNo', max_length=20)  # Field name made lowercase.
    apiaccountid = models.CharField(db_column='APIAccountID', max_length=32, blank=True,
                                    null=True)  # Field name made lowercase.
    apiinvestorid = models.CharField(db_column='APIInvestorID', max_length=20, blank=True,
                                     null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_customerchannelrel_paper'
        unique_together = (('id', 'customerid', 'accountid'),)


class Customerchannelrel(models.Model):
    id = models.AutoField(db_column='ID', primary_key=True)  # Field name made lowercase.
    customerid = models.CharField(db_column='CustomerID', max_length=20)  # Field name made lowercase.
    tdchannelid = models.CharField(db_column='TDChannelID', max_length=31, blank=True,
                                   null=True)  # Field name made lowercase.
    mdchannelid = models.CharField(db_column='MDChannelID', max_length=31, blank=True,
                                   null=True)  # Field name made lowercase.
    accountid = models.CharField(db_column='AccountID', max_length=32)  # Field name made lowercase.
    tdapitype = models.CharField(db_column='TDApiType', max_length=1, blank=True,
                                 null=True)  # Field name made lowercase.
    assetno = models.CharField(db_column='AssetNo', max_length=16)  # Field name made lowercase.
    combino = models.CharField(db_column='CombiNo', max_length=20)  # Field name made lowercase.
    apiaccountid = models.CharField(db_column='APIAccountID', max_length=32, blank=True,
                                    null=True)  # Field name made lowercase.
    apiinvestorid = models.CharField(db_column='APIInvestorID', max_length=20, blank=True,
                                     null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_customerchannelrel'
        unique_together = (('id', 'customerid', 'accountid'),)


class Paperrun(models.Model):
    stgid = models.IntegerField(db_column='StgID', primary_key=True)  # Field name made lowercase.
    creattime = models.CharField(db_column='CreatTime', max_length=19)  # Field name made lowercase.
    starttime = models.CharField(db_column='StartTime', max_length=19)  # Field name made lowercase.
    endtime = models.CharField(db_column='EndTime', max_length=19)  # Field name made lowercase.
    envid = models.CharField(db_column='EnvID', max_length=20)  # Field name made lowercase.
    runstatus = models.CharField(db_column='RunStatus', max_length=1)  # Field name made lowercase.
    runmsg = models.CharField(db_column='RunMsg', max_length=2000)  # Field name made lowercase.
    isavailable = models.SmallIntegerField(db_column='IsAvailable')  # Field name made lowercase.
    stoptime = models.CharField(db_column='StopTime', max_length=19)  # Field name made lowercase.
    runpath = models.CharField(db_column='RunPath', max_length=1000)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_paperrun'


class Liverun(models.Model):
    stgid = models.IntegerField(db_column='StgID', primary_key=True)  # Field name made lowercase.
    creattime = models.CharField(db_column='CreatTime', max_length=19)  # Field name made lowercase.
    starttime = models.CharField(db_column='StartTime', max_length=19)  # Field name made lowercase.
    endtime = models.CharField(db_column='EndTime', max_length=19)  # Field name made lowercase.
    envid = models.CharField(db_column='EnvID', max_length=20)  # Field name made lowercase.
    runstatus = models.CharField(db_column='RunStatus', max_length=1)  # Field name made lowercase.
    runmsg = models.CharField(db_column='RunMsg', max_length=2000)  # Field name made lowercase.
    isavailable = models.SmallIntegerField(db_column='IsAvailable')  # Field name made lowercase.
    stoptime = models.CharField(db_column='StopTime', max_length=19)  # Field name made lowercase.
    runpath = models.CharField(db_column='RunPath', max_length=1000)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_liverun'


class RuleLive(models.Model):
    id = models.AutoField(db_column='ID', primary_key=True)  # Field name made lowercase.
    ruleid = models.IntegerField(db_column='RuleID')  # Field name made lowercase.
    rulepath = models.CharField(db_column='RulePath', max_length=256)  # Field name made lowercase.
    ruleversion = models.CharField(db_column='RuleVersion', max_length=31)  # Field name made lowercase.
    rulename = models.CharField(db_column='RuleName', max_length=31)  # Field name made lowercase.
    ruletype = models.CharField(db_column='RuleType', max_length=1, blank=True, null=True)  # Field name made lowercase.
    configpath = models.CharField(db_column='ConfigPath', max_length=256)  # Field name made lowercase.
    customerid = models.CharField(db_column='CustomerID', max_length=20)  # Field name made lowercase.
    isclientloaded = models.SmallIntegerField(db_column='IsClientLoaded', blank=True,
                                              null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_rule_live'
        unique_together = (('id', 'ruleid', 'customerid'),)


class RulePaper(models.Model):
    id = models.AutoField(db_column='ID', primary_key=True)  # Field name made lowercase.
    ruleid = models.IntegerField(db_column='RuleID')  # Field name made lowercase.
    rulepath = models.CharField(db_column='RulePath', max_length=256)  # Field name made lowercase.
    ruleversion = models.CharField(db_column='RuleVersion', max_length=31)  # Field name made lowercase.
    rulename = models.CharField(db_column='RuleName', max_length=31)  # Field name made lowercase.
    ruletype = models.CharField(db_column='RuleType', max_length=1, blank=True, null=True)  # Field name made lowercase.
    configpath = models.CharField(db_column='ConfigPath', max_length=256)  # Field name made lowercase.
    customerid = models.CharField(db_column='CustomerID', max_length=20)  # Field name made lowercase.
    isclientloaded = models.SmallIntegerField(db_column='IsClientLoaded', blank=True,
                                              null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_rule_paper'
        unique_together = (('id', 'ruleid', 'customerid'),)


class Rule(models.Model):
    id = models.AutoField(db_column='ID', primary_key=True)  # Field name made lowercase.
    ruleid = models.IntegerField(db_column='RuleID')  # Field name made lowercase.
    rulepath = models.CharField(db_column='RulePath', max_length=256)  # Field name made lowercase.
    ruleversion = models.CharField(db_column='RuleVersion', max_length=31)  # Field name made lowercase.
    rulename = models.CharField(db_column='RuleName', max_length=31)  # Field name made lowercase.
    ruletype = models.CharField(db_column='RuleType', max_length=1, blank=True, null=True)  # Field name made lowercase.
    configpath = models.CharField(db_column='ConfigPath', max_length=256)  # Field name made lowercase.
    customerid = models.CharField(db_column='CustomerID', max_length=20)  # Field name made lowercase.
    isclientloaded = models.SmallIntegerField(db_column='IsClientLoaded', blank=True,
                                              null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_rule'
        unique_together = (('id', 'ruleid', 'customerid'),)


class Ruleorder(models.Model):
    frontid = models.IntegerField(db_column='FrontID')  # Field name made lowercase.
    sessionid = models.IntegerField(db_column='SessionID')  # Field name made lowercase.
    accountid = models.CharField(db_column='AccountID', max_length=32)  # Field name made lowercase.
    assetno = models.CharField(db_column='AssetNo', max_length=16)  # Field name made lowercase.
    combino = models.CharField(db_column='CombiNo', max_length=20)  # Field name made lowercase.
    exchangeid = models.CharField(db_column='ExchangeID', max_length=10)  # Field name made lowercase.
    commoditytype = models.CharField(db_column='CommodityType', max_length=1, blank=True,
                                     null=True)  # Field name made lowercase.
    instrumentid = models.CharField(db_column='InstrumentID', max_length=30)  # Field name made lowercase.
    instrumentname = models.CharField(db_column='InstrumentName', max_length=128, blank=True,
                                      null=True)  # Field name made lowercase.
    orderpricetype = models.CharField(db_column='OrderPriceType', max_length=1)  # Field name made lowercase.
    direction = models.CharField(db_column='Direction', max_length=1, blank=True,
                                 null=True)  # Field name made lowercase.
    offsetflag = models.CharField(db_column='OffsetFlag', max_length=1, blank=True,
                                  null=True)  # Field name made lowercase.
    hedgeflag = models.CharField(db_column='HedgeFlag', max_length=1, blank=True,
                                 null=True)  # Field name made lowercase.
    price = models.FloatField(db_column='Price')  # Field name made lowercase.
    volume = models.BigIntegerField(db_column='Volume')  # Field name made lowercase.
    timecondition = models.CharField(db_column='TimeCondition', max_length=1, blank=True,
                                     null=True)  # Field name made lowercase.
    ruleid = models.IntegerField(db_column='RuleID', blank=True, null=True)  # Field name made lowercase.
    customerid = models.CharField(db_column='CustomerID', max_length=20)  # Field name made lowercase.
    bilateralid = models.CharField(db_column='BilateralID', max_length=12, blank=True,
                                   null=True)  # Field name made lowercase.
    purchaseway = models.CharField(db_column='PurchaseWay', max_length=1, blank=True,
                                   null=True)  # Field name made lowercase.
    text = models.CharField(db_column='Text', max_length=200, blank=True, null=True)  # Field name made lowercase.
    ytm = models.FloatField(db_column='YTM')  # Field name made lowercase.
    strikeyeild = models.FloatField(db_column='StrikeYeild')  # Field name made lowercase.
    quotetype = models.SmallIntegerField(db_column='QuoteType')  # Field name made lowercase.
    maxfloor = models.BigIntegerField(db_column='MaxFloor', blank=True, null=True)  # Field name made lowercase.
    minticksize = models.BigIntegerField(db_column='MinTickSize', blank=True, null=True)  # Field name made lowercase.
    legsettltype = models.SmallIntegerField(db_column='LegSettlType', blank=True,
                                            null=True)  # Field name made lowercase.
    matchtype = models.SmallIntegerField(db_column='MatchType', blank=True, null=True)  # Field name made lowercase.
    deliverytype = models.SmallIntegerField(db_column='DeliveryType', blank=True,
                                            null=True)  # Field name made lowercase.
    clearingmethod = models.SmallIntegerField(db_column='ClearingMethod', blank=True,
                                              null=True)  # Field name made lowercase.
    quoteid = models.CharField(db_column='QuoteID', max_length=30, blank=True, null=True)  # Field name made lowercase.
    validuntiltime = models.CharField(db_column='ValidUntilTime', max_length=24, blank=True,
                                      null=True)  # Field name made lowercase.
    mdentrytime = models.CharField(db_column='MDEntryTime', max_length=24, blank=True,
                                   null=True)  # Field name made lowercase.
    clordid = models.CharField(db_column='ClOrdID', max_length=30, blank=True, null=True)  # Field name made lowercase.
    routingtype = models.SmallIntegerField(db_column='RoutingType', blank=True, null=True)  # Field name made lowercase.
    marketindicator = models.SmallIntegerField(db_column='MarketIndicator', blank=True,
                                               null=True)  # Field name made lowercase.
    realtimeundertakeflag = models.SmallIntegerField(db_column='RealTimeUndertakeFlag', blank=True,
                                                     null=True)  # Field name made lowercase.
    subjectpartytype = models.SmallIntegerField(db_column='SubjectPartyType', blank=True,
                                                null=True)  # Field name made lowercase.
    orderinnerid = models.CharField(db_column='OrderInnerID', max_length=12,
                                    primary_key=True)  # Field name made lowercase.
    ordersysid = models.CharField(db_column='OrderSysID', max_length=20, blank=True,
                                  null=True)  # Field name made lowercase.
    inserttime = models.CharField(db_column='InsertTime', max_length=8)  # Field name made lowercase.
    reserver1 = models.CharField(db_column='Reserver1', max_length=30, blank=True,
                                 null=True)  # Field name made lowercase.
    reserver2 = models.CharField(db_column='Reserver2', max_length=30, blank=True,
                                 null=True)  # Field name made lowercase.
    reserver3 = models.CharField(db_column='Reserver3', max_length=30, blank=True,
                                 null=True)  # Field name made lowercase.
    reserver4 = models.CharField(db_column='Reserver4', max_length=30, blank=True,
                                 null=True)  # Field name made lowercase.
    tradingday = models.CharField(db_column='TradingDay', max_length=8)  # Field name made lowercase.
    tradeprice = models.FloatField(db_column='TradePrice')  # Field name made lowercase.
    # avgtradeprice = models.FloatField(db_column='AvgTradePrice')  # Field name made lowercase.
    volumetraded = models.BigIntegerField(db_column='VolumeTraded')  # Field name made lowercase.
    volumetotal = models.BigIntegerField(db_column='VolumeTotal')  # Field name made lowercase.
    ordersubmitstatus = models.CharField(db_column='OrderSubmitStatus', max_length=1)  # Field name made lowercase.
    orderstatus = models.CharField(db_column='OrderStatus', max_length=1)  # Field name made lowercase.
    insertdate = models.CharField(db_column='InsertDate', max_length=8, blank=True,
                                  null=True)  # Field name made lowercase.
    updatedate = models.CharField(db_column='UpdateDate', max_length=8, blank=True,
                                  null=True)  # Field name made lowercase.
    updatetime = models.CharField(db_column='UpdateTime', max_length=8, blank=True,
                                  null=True)  # Field name made lowercase.
    canceltime = models.CharField(db_column='CancelTime', max_length=8, blank=True,
                                  null=True)  # Field name made lowercase.
    errorcode = models.IntegerField(db_column='ErrorCode')  # Field name made lowercase.
    statusmsg = models.CharField(db_column='StatusMsg', max_length=200, blank=True,
                                 null=True)  # Field name made lowercase.
    settlementid = models.IntegerField(db_column='SettlementID')  # Field name made lowercase.
    ordersource = models.CharField(db_column='OrderSource', max_length=1)  # Field name made lowercase.
    clientid = models.CharField(db_column='ClientID', max_length=22, blank=True,
                                null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'T_ruleorder'
        # db_table = 'T_RuleOrder'
        # app_label = 'mysql'  # 使用mysql数据库
        # db_table = 'app2_fruit'  # 指定表名为app2_fruit


class Ruleposition(models.Model):
    tradingday = models.CharField(db_column='TradingDay', primary_key=True, max_length=8)  # Field name made lowercase.
    exchangeid = models.CharField(db_column='ExchangeID', max_length=10)  # Field name made lowercase.
    commodityid = models.CharField(db_column='CommodityID', max_length=10, blank=True,
                                   null=True)  # Field name made lowercase.
    exchangeinstid = models.CharField(db_column='ExchangeInstID', max_length=30, blank=True,
                                      null=True)  # Field name made lowercase.
    instrumentid = models.CharField(db_column='InstrumentID', max_length=30)  # Field name made lowercase.
    posidirection = models.CharField(db_column='PosiDirection', max_length=1)  # Field name made lowercase.
    hedgeflag = models.CharField(db_column='HedgeFlag', max_length=1)  # Field name made lowercase.
    positionprofitbydate = models.FloatField(db_column='PositionProfitByDate')  # Field name made lowercase.
    positionprofitbytrade = models.FloatField(db_column='PositionProfitByTrade')  # Field name made lowercase.
    closeprofitbydate = models.FloatField(db_column='CloseProfitByDate')  # Field name made lowercase.
    closeprofitbytrade = models.FloatField(db_column='CloseProfitByTrade')  # Field name made lowercase.
    positiondate = models.CharField(db_column='PositionDate', max_length=1)  # Field name made lowercase.
    ydposition = models.BigIntegerField(db_column='YdPosition')  # Field name made lowercase.
    position = models.BigIntegerField(db_column='Position')  # Field name made lowercase.
    todayposition = models.BigIntegerField(db_column='TodayPosition')  # Field name made lowercase.
    frozenposition = models.BigIntegerField(db_column='FrozenPosition')  # Field name made lowercase.
    frozenamount = models.FloatField(db_column='FrozenAmount')  # Field name made lowercase.
    openvolume = models.BigIntegerField(db_column='OpenVolume')  # Field name made lowercase.
    closevolume = models.BigIntegerField(db_column='CloseVolume')  # Field name made lowercase.
    openamount = models.FloatField(db_column='OpenAmount')  # Field name made lowercase.
    closeamount = models.FloatField(db_column='CloseAmount')  # Field name made lowercase.
    positioncost = models.FloatField(db_column='PositionCost')  # Field name made lowercase.
    opencost = models.FloatField(db_column='OpenCost')  # Field name made lowercase.
    premargin = models.FloatField(db_column='PreMargin')  # Field name made lowercase.
    usemargin = models.FloatField(db_column='UseMargin')  # Field name made lowercase.
    frozenmargin = models.FloatField(db_column='FrozenMargin')  # Field name made lowercase.
    frozencash = models.FloatField(db_column='FrozenCash')  # Field name made lowercase.
    frozencommission = models.FloatField(db_column='FrozenCommission')  # Field name made lowercase.
    adjust = models.FloatField(db_column='Adjust')  # Field name made lowercase.
    tradecommission = models.FloatField(db_column='TradeCommission')  # Field name made lowercase.
    presettlementprice = models.FloatField(db_column='PreSettlementPrice')  # Field name made lowercase.
    ruleid = models.IntegerField(db_column='RuleID')  # Field name made lowercase.
    customerid = models.CharField(db_column='CustomerID', max_length=20, blank=True,
                                  null=True)  # Field name made lowercase.
    traderid = models.CharField(db_column='TraderID', max_length=20, blank=True,
                                null=True)  # Field name made lowercase.
    assetno = models.CharField(db_column='AssetNo', max_length=16)  # Field name made lowercase.
    combino = models.CharField(db_column='CombiNo', max_length=20)  # Field name made lowercase.
    longfrozen = models.BigIntegerField(db_column='LongFrozen')  # Field name made lowercase.
    shortfrozen = models.BigIntegerField(db_column='ShortFrozen')  # Field name made lowercase.
    longfrozenamount = models.FloatField(db_column='LongFrozenAmount')  # Field name made lowercase.
    shortfrozenamount = models.FloatField(db_column='ShortFrozenAmount')  # Field name made lowercase.
    marginratebyvolume = models.FloatField(db_column='MarginRateByVolume')  # Field name made lowercase.
    marginratebymoney = models.FloatField(db_column='MarginRateByMoney')  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_ruleposition'
        unique_together = (
            ('tradingday', 'instrumentid', 'posidirection', 'hedgeflag', 'positiondate', 'ruleid', 'assetno',
             'combino'),)


class Ruletrade(models.Model):
    exchangeid = models.CharField(db_column='ExchangeID', max_length=10)  # Field name made lowercase.
    tradingday = models.CharField(db_column='TradingDay', max_length=8)  # Field name made lowercase.
    tradeid = models.CharField(db_column='TradeID', max_length=70, primary_key=True)  # Field name made lowercase.
    ordersysid = models.CharField(db_column='OrderSysID', max_length=20)  # Field name made lowercase.
    orderinnerid = models.CharField(db_column='OrderInnerID', max_length=12)  # Field name made lowercase.
    commodityid = models.CharField(db_column='CommodityID', max_length=10, blank=True,
                                   null=True)  # Field name made lowercase.
    instrumentid = models.CharField(db_column='InstrumentID', max_length=30)  # Field name made lowercase.
    userid = models.CharField(db_column='UserID', max_length=20)  # Field name made lowercase.
    direction = models.CharField(db_column='Direction', max_length=1, blank=True,
                                 null=True)  # Field name made lowercase.
    offsetflag = models.CharField(db_column='OffsetFlag', max_length=1, blank=True,
                                  null=True)  # Field name made lowercase.
    hedgeflag = models.CharField(db_column='HedgeFlag', max_length=1, blank=True,
                                 null=True)  # Field name made lowercase.
    orderprice = models.FloatField(db_column='OrderPrice')  # Field name made lowercase.
    tradeprice = models.FloatField(db_column='TradePrice')  # Field name made lowercase.
    ytm = models.FloatField(db_column='YTM')  # Field name made lowercase.
    volumetraded = models.BigIntegerField(db_column='VolumeTraded')  # Field name made lowercase.
    tradedate = models.CharField(db_column='TradeDate', max_length=8)  # Field name made lowercase.
    tradetime = models.CharField(db_column='TradeTime', max_length=8)  # Field name made lowercase.
    tradefee = models.FloatField(db_column='TradeFee')  # Field name made lowercase.
    currencyid = models.CharField(db_column='CurrencyID', max_length=10, blank=True,
                                  null=True)  # Field name made lowercase.
    manualfee = models.CharField(db_column='ManualFee', max_length=1, blank=True,
                                 null=True)  # Field name made lowercase.
    deleted = models.CharField(db_column='Deleted', max_length=1, blank=True, null=True)  # Field name made lowercase.
    coverprice = models.FloatField(db_column='CoverPrice', blank=True, null=True)  # Field name made lowercase.
    exchangeinstid = models.CharField(db_column='ExchangeInstID', max_length=30, blank=True,
                                      null=True)  # Field name made lowercase.
    brokerid = models.CharField(db_column='BrokerID', max_length=10, blank=True,
                                null=True)  # Field name made lowercase.
    investorid = models.CharField(db_column='InvestorID', max_length=20, blank=True,
                                  null=True)  # Field name made lowercase.
    ruleid = models.IntegerField(db_column='RuleID', blank=True, null=True)  # Field name made lowercase.
    customerid = models.CharField(db_column='CustomerID', max_length=20)  # Field name made lowercase.
    accountid = models.CharField(db_column='AccountID', max_length=32)  # Field name made lowercase.
    commoditytype = models.CharField(db_column='CommodityType', max_length=1)  # Field name made lowercase.
    assetno = models.CharField(db_column='AssetNo', max_length=16)  # Field name made lowercase.
    combino = models.CharField(db_column='CombiNo', max_length=20)  # Field name made lowercase.
    bilateralid = models.CharField(db_column='BilateralID', max_length=12, blank=True,
                                   null=True)  # Field name made lowercase.
    clientid = models.CharField(db_column='ClientID', max_length=22, blank=True,
                                null=True)  # Field name made lowercase.
    quotetype = models.SmallIntegerField(db_column='QuoteType', blank=True, null=True)  # Field name made lowercase.
    legsettltype = models.SmallIntegerField(db_column='LegSettlType', blank=True,
                                            null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_ruletrade'


class Stcriskinfo(models.Model):
    risktype = models.CharField(db_column='RiskType', primary_key=True, max_length=30)  # Field name made lowercase.
    riskindicator = models.CharField(db_column='RiskIndicator', max_length=30, blank=True,
                                     null=True)  # Field name made lowercase.
    risksource = models.CharField(db_column='RiskSource', max_length=30, blank=True,
                                  null=True)  # Field name made lowercase.
    riskvalue = models.CharField(db_column='RiskValue', max_length=200, blank=True,
                                 null=True)  # Field name made lowercase.
    orderinnerid = models.CharField(db_column='OrderInnerID', max_length=12)  # Field name made lowercase.
    bondid = models.CharField(db_column='BondID', max_length=30)  # Field name made lowercase.
    direction = models.CharField(db_column='Direction', max_length=1)  # Field name made lowercase.
    settletype = models.SmallIntegerField(db_column='SettleType')  # Field name made lowercase.
    price = models.FloatField(db_column='Price')  # Field name made lowercase.
    volume = models.BigIntegerField(db_column='Volume')  # Field name made lowercase.
    orderinsertdate = models.CharField(db_column='OrderInsertDate', max_length=8, blank=True,
                                       null=True)  # Field name made lowercase.
    orderinserttime = models.CharField(db_column='OrderInsertTime', max_length=8, blank=True,
                                       null=True)  # Field name made lowercase.
    ruleid = models.IntegerField(db_column='RuleID')  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_stcriskinfo'
        unique_together = (('risktype', 'orderinnerid'),)


class Rulemessage(models.Model):
    '''
    策略日志表
    '''
    timestamp = models.CharField(db_column='TimeStamp', primary_key=True, max_length=19)  # Field name made lowercase.
    ruleid = models.IntegerField(db_column='RuleID')  # Field name made lowercase.
    messagelevel = models.CharField(db_column='MessageLevel', max_length=1, blank=True,
                                    null=True)  # Field name made lowercase.
    message = models.CharField(db_column='Message', max_length=200, blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 't_rulemessage'
        unique_together = (('timestamp', 'ruleid'),)


class ManualTradePaper(models.Model):
    """
    人工录入表（仿真）
    """
    blocknum = models.CharField(db_column="BlockNum", max_length=30, primary_key=True)
    direction = models.CharField(db_column="Direction", max_length=1)
    transactime = models.CharField(db_column="TransactTime", max_length=19)
    ytm = models.FloatField(db_column="YTM")
    volume = models.BigIntegerField(db_column="Volume")
    settletype = models.SmallIntegerField(db_column="SettleType")
    bondid = models.CharField(db_column="BondID", max_length=30)
    netprice = models.FloatField(db_column="NetPrice")
    ruleid = models.IntegerField(db_column="RuleID")
    customerid = models.CharField(db_column="CustomerID", max_length=20)

    class Meta:
        db_table = "t_papermanualtrade"
        unique_together = (('blocknum', 'direction'),)


class ManualTradeLive(models.Model):
    """
    人工录入表（实盘）
    """
    blocknum = models.CharField(db_column="BlockNum", max_length=30, primary_key=True)
    direction = models.CharField(db_column="Direction", max_length=1)
    transactime = models.CharField(db_column="TransactTime", max_length=19)
    ytm = models.FloatField(db_column="YTM")
    volume = models.BigIntegerField(db_column="Volume")
    settletype = models.SmallIntegerField(db_column="SettleType")
    bondid = models.CharField(db_column="BondID", max_length=30)
    netprice = models.FloatField(db_column="NetPrice")
    ruleid = models.IntegerField(db_column="RuleID")
    customerid = models.CharField(db_column="CustomerID", max_length=20)

    class Meta:
        db_table = "t_livemanualtrade"
        unique_together = (('blocknum', 'direction'),)


class Transfer(models.Model):
    """
    移交策略表
    """
    id = models.AutoField(db_column='ID', primary_key=True)  # Field name made lowercase
    ruleid = models.IntegerField(db_column="RuleID", null=False)
    stgroup = models.CharField(db_column="StgGroup", max_length=1)
    orignalowner = models.CharField(db_column="OrignalOwner", max_length=20, null=False)
    newowner = models.CharField(db_column="NewOwner", max_length=20)
    applydatetime = models.CharField(db_column="ApplyDateTime", max_length=24)
    approvaldatetime = models.CharField(db_column="ApprovalDateTime", max_length=24)
    auditstatus = models.CharField(db_column="AuditStatus", max_length=1, null=False)
    stgname = models.CharField(db_column='StgName', max_length=50)

    class Meta:
        db_table = "t_transfer"
